function ValidaCTPS(campo)
{
  if (campo.value != '') {
     var CTPS = campo.value;

     while (CTPS.indexOf("-") != -1)
	    CTPS = CTPS.replace("-","");

	 if (CTPS == '0000000'
	  || CTPS == '1111111'
	  || CTPS == '2222222'
	  || CTPS == '3333333'
	  || CTPS == '4444444'
	  || CTPS == '5555555'
	  || CTPS == '6666666'
	  || CTPS == '7777777'
	  || CTPS == '8888888'
	  || CTPS == '9999999')
	 	return false;

     return true;
    }  
}

function MascaraCTPS(campo,w)
{
    var strCheck = '0123456789';
    var whichCode = (window.Event) ? w.which : w.keyCode;
    var key = String.fromCharCode(whichCode);
	var CTPS = SoNumero(campo.value);
	var CTPSAux = '';
	
	if (strCheck.indexOf(key) == -1) w.returnValue = false;
	
	if (whichCode != 8 && CTPS.length < 8)
	{
		for (var i=0; i< CTPS.length; i++)
		{
			CTPSAux = CTPSAux + CTPS.substr(i,1);
			if (i == 5)
			{
				CTPSAux = CTPSAux + "-";
			}
		}
		campo.value = CTPSAux;
	}
	else
	{
		campo.value = campo.value.substr(0,8);
	}
}